package com.google.gwt.sample.stockwatcher.server;

import com.google.gwt.sample.stockwatcher.client.Idd;
import com.google.gwt.sample.stockwatcher.client.StockPrice;
import com.google.gwt.sample.stockwatcher.client.StockPriceService2;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import util.HibernateUtil;

@SuppressWarnings("serial")
public class StockPriceServiceImpl2 extends RemoteServiceServlet implements StockPriceService2{
	public Idd getId(Idd id){
		Idd news=new Idd();
		Integer idd =0;
		idd=id.getId();
		news.setId(idd);
		
		Session sess = HibernateUtil.getSessionFactory().getCurrentSession();

		//Session sess = HibernateUtil.currentSession();
		sess.beginTransaction();
		Object book = (StockPrice) sess.load(StockPrice.class, idd);
		sess.delete(book);
		sess.getTransaction().commit();
		sess.close();
        /*		
			Statement statement = null;
			Connection con = null;
			try {
			con = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5433/postgres", "postgres", "hr");
			statement = con.createStatement();
			statement.executeQuery("DELETE FROM \"manual\" WHERE id="+idd);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}*/
			return id;
		
	}
}